package com.borrowing.controller;

import com.borrowing.entity.Result;
import com.borrowing.entity.pojo.User;
import com.borrowing.entity.pojo.dto.FollowDto;
import com.borrowing.entity.pojo.dto.QueryDto;
import com.borrowing.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 用户
 * */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Resource
    private UserService userService;

    /**
     * 注册
     * @param userName 用户昵称
     * @return
     */
    @PostMapping
    public Result registration(String userName){
        return userService.registration(userName);
    }

    /**
     * 关注
     * @param followDto
     * @return
     */
    @PostMapping("follow")
    public Result follow(@RequestBody FollowDto followDto){
        return userService.follow(followDto);
    }

    /**
     * 查询用户关注者
     * @param queryDto
     * @return
     */
    @GetMapping
    public Result<List<User>> query(QueryDto queryDto){
        return userService.queryUser(queryDto);
    }

}
